﻿namespace PC1
{
    /// <summary>
    /// Rd - destination register.
    /// Rs - first source register.
    /// Rt - second source register.
    /// </summary>
    public enum Opcode : byte
    {
        HLT = 0x00,

        /// <summary>
        /// M[0]       
        /// ADD{S}{B} Rd, Rs, Rt
        /// IF B THEN Rd = Rs + Rt
        /// </summary>
        ADD = 0x01,

        /// <summary>
        /// M[0]       
        /// SUB [B] R0 R1 R2
        /// IF B THEN R0 = R1 - R2
        /// </summary>
        SUB = 0x02,

        INC,
        DEC,

        /// <summary>
        /// M[0]       
        /// AND [B] R0 R1 R2
        /// IF B THEN R0 = R1 & R2
        /// </summary>
        AND = 0x03,

        /// <summary>
        /// M[0]       
        /// ORR [B] R0 R1 R2
        /// IF B THEN R0 = R1 | R2
        /// </summary>
        ORR = 0x04,

        /// <summary>
        /// M[0]       
        /// EOR [B] R0 R1 R2
        /// IF B THEN R0 = R1 ^ R2
        /// </summary>
        EOR = 0x05,

        NOT,
        NEG,

        LSL = 0x07,

        LSR = 0x08,

        ASL,
        ASR,

        CSL,
        CSR,

        /// <summary>
        /// M[0]     
        /// CMP Ra Rb
        /// B = compare(Ra, Rb)
        /// </summary>
        CMP = 0x06,

        B = 0x09,

        /// <summary>
        /// M[0]       M[1]
        /// LDR [B] Ri adr
        /// IF B THEN Ri=m[adr]
        /// </summary>
        LDR = 0x0A,

        /// <summary>
        /// M[0]       M[1]
        /// STR [B] Ri adr
        /// IF B THEN m[adr]=Ri
        /// </summary>
        STR = 0x0B,

        /// <summary>
        /// M[0]       M[1]
        /// MOV [B] Ri val
        /// IF B THEN Ri=val
        /// </summary>
        MOV = 0x0C,

        SWP,

        CLL,
        RET,

        PUSH,
        POP,
    }

    public enum Bcode : byte
    {
        UN = 0x00,
        EQ = 0x01,
        NQ = 0x02,
        LT = 0x03,
        LE = 0x04,
        GT = 0x05,
        GE = 0x06
    }
}